package com.zb.zbtcommon.controller;

import com.zb.zbtcommon.dto.ResponseEntity;
import com.zb.zbtcommon.entity.Headoffice;
import com.zb.zbtcommon.service.HeadofficeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/zbt/common/headoffice")
@Api(value = "HeadofficeController公司详情控制器")
public class HeadofficeController {
    private Logger logger = LoggerFactory.getLogger(HeadofficeController.class);
    @Autowired
    private HeadofficeService headofficeService;

    @RequestMapping(value = "/findheadoffice")

    @ApiOperation("查询子公司详细信息")
    @ApiImplicitParam(paramType="query", name = "headofficeid", value = "子公司的ID类型headofficeid", required = true, dataType = "String")
    public ResponseEntity<Headoffice> findHeadoffice(String headofficeid){

        ResponseEntity entity =null;
        try {
            entity=new ResponseEntity();
            Headoffice headoffice=headofficeService.findHeadoffice(headofficeid);
            if (headoffice!=null) {
                entity.setCode(HttpStatus.OK.value());
                entity.setTarget(headoffice);
            }
        } catch (Exception e) {
            logger.error("/zbt/common/headoffice/findheadoffice   请求参数：headofficeid"+headofficeid+"      异常信息"+e.getMessage());
            e.printStackTrace();
            entity.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
            entity.setMessage("查询子公司详细信息错误");
        }
        return  entity;

    }
}
